package org.wuqi.microdataservice.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wuqi.api.model.ProductDetail;
import org.wuqi.api.model.UserList;
import org.wuqi.api.service.ProductInfo;
import org.wuqi.bean.LoanInfo;
import org.wuqi.microdataservice.mapper.BidInfoMapper;
import org.wuqi.microdataservice.mapper.FinanceAccountMapper;
import org.wuqi.microdataservice.mapper.LoanInfoMapper;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author jjj
 * @program: earnest-money
 * @description:TODO
 * @date 2023-12-19 16:48:17
 */
@DubboService(interfaceClass = ProductInfo.class ,version = "1")
@Service
public class ProductInfoImpl implements ProductInfo {
    @Autowired
    private LoanInfoMapper loanInfoMapper;
    @Autowired
    private BidInfoMapper bidInfoMapper;
    @Autowired
    private FinanceAccountMapper financeAccountMapper;
    @Override
    public List<LoanInfo> selectProductList(Map<String, Object> product) {
        Integer pageSize = (Integer) product.get("pageSize");
        Integer pageNum = (Integer) product.get("pageNum");
        List<LoanInfo> loanInfos = loanInfoMapper.selectLoanInfo();
        return loanInfos;
    }
    @Override
    public ProductDetail selectDetail(Integer productId) {
//        首先获取详情信息
        LoanInfo loanInfo = loanInfoMapper.selectByPrimaryKey(productId);
//        获取募捐剩余金额
        BigDecimal money = bidInfoMapper.selectSumMoney(loanInfo.getId());
//        获取募捐列表信息
        List<UserList> userLists = bidInfoMapper.selectInvestList();
        ProductDetail productDetail = new ProductDetail(loanInfo, money, userLists);
        return productDetail;
    }
}
 
 